package com.xxzuibang.day16.arrays类;

import java.util.Arrays;
import java.util.Comparator;

public class ArraysMethod {
    public static void main(String[] args) {
        //排序方法sort
        Integer[] integers = {1, 20, 90};
        System.out.println(Arrays.toString(integers));
        //使用sort方法,
        Integer[] arr = {1, -1, 7, 0, 89};
        /*Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                Integer i1=o1;
                Integer i2=o2;
                return i2-i1;
            }
        });*/
        Arrays.sort(arr, (o1, o2) -> o2 - o1);//降序排列
        System.out.println("排序后：");
        System.out.println(Arrays.toString(arr));
    }
}
